// Interpolator.h - MARIN MSG Anneke Sicherer-Roetman 20081105

#ifndef INTERPOLATOR_H
#define INTERPOLATOR_H

#include "Array1D.h"

/// Polynomial interpolation of a given 2D dataset with Chebyshev polynomials of the first kind
/** Chebyshev polynomials are important in approximation theory because the roots 
 *  of the Chebyshev polynomials of the first kind, which are also called Chebyshev
 *  nodes, are used as nodes in polynomial interpolation. The resulting interpolation
 *  polynomial minimizes the problem of Runge's phenomenon and provides an approximation
 *  that is close to the polynomial of best approximation to a continuous function under
 *  the maximum norm.  See http://en.wikipedia.org/wiki/Chebyshev_polynomials */

class Interpolator
{
    
public:
    
    Interpolator(const Array1D<double> &x,
                 const Array1D<double> &y);
    
    virtual ~Interpolator();
    
    void interpolate(int n, Array1D<double> *x, Array1D<double> *y);
    
private:
    
    Interpolator();
    
    const Array1D<double> &m_x;       ///< original x coordinates
    const Array1D<double> &m_y;       ///< original y coordinates
    Array1D<double> m_t;              ///< Chebyshev nodes
};

#endif // INTERPOLATOR_H
